import random
import time
import json
import string
from datetime import date,timedelta

class CreateRanDom():
    def r_string(self):#生成随机字符串
        data="1234567890zxcvbnmlkjhgfdsaqwertyuiop"
        #用时间来做随机播种
        random.seed(time.time())
        #随机选取数据
        sa=[]
        for i in range(20):
            sa.append(random.choice(data))
        salt="gp_"+''.join(sa)
        # print(salt)
        return salt

class Randoms():
    # 获取26个大小写字母
    letters = string.ascii_letters
    # 获取26个小写字母
    Lowercase_letters = string.ascii_lowercase
    # 获取26个大写字母
    Capital = string.ascii_uppercase
    # 获取阿拉伯数字
    digits = string.digits

    #随机code
    def code(self):
        # s是小写字母和数字的集合
        s = Randoms.Lowercase_letters+Randoms.digits
        #生成28位小写和数字的集合，并将列表转字符串
        code=''.join(random.sample(s,28))
        print('随机code:%s'%code)
        return code

    #随机税号
    # def tax_code(self):
    #     list_1=['I','O','Z','S','V']
    #     list_2=[]
    #     #新建容器list_2放置过滤后的数据
    #     #添加过滤条件,数据源不在list_1中，即需要的数据
    #     #将过滤后的数据放进list_2中
    #     for j  in  randoms().Capital:
    #         if j not in list_1:
    #             list_2.append(j)
    #     s =''.join(list_2)  + randoms().digits
    #     #print(s)
    #     tax_code=''.join(random.sample(s,18))
    #     print('随机税号:%s'%tax_code)
    #     return tax_code

    def tax_code(self):  # 生成随机字符串
        data = "1234567890xcbnmlkjhgfdaqwertyup"
        # 用时间来做随机播种
        random.seed(time.time())
        # 随机选取数据
        sa = []
        for i in range(10):
            sa.append(random.choice(data))
        salt_code = "GAPEN" + ''.join(sa)
        # print(salt)
        print('随机税号:%s' % salt_code)
        return salt_code

    def sub_acc(self):  # 生成随机子账号
        data = "1234567890zxcvbnmlkjhgfdsaqwertyuiop"
        # 用时间来做随机播种
        random.seed(time.time())
        # 随机选取数据
        sa = []
        for i in range(10):
            sa.append(random.choice(data))
        salt_code = "TEST" + ''.join(sa)
        # print(salt)
        print('随机税号:%s' % salt_code)
        return salt_code

    def telephone(self):
        # 第二位数字
        second = [3, 4, 5, 7, 8][random.randint(0, 4)]

        # 第三位数字
        third = {
            3: random.randint(0, 9),
            4: [5, 7, 9][random.randint(0, 2)],
            5: [i for i in range(10) if i != 4][random.randint(0, 8)],
            7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
            8: random.randint(0, 9),
        }[second]

        # 最后八位数字
        suffix = random.randint(10000000, 99999999)

        # 拼接手机号
        telephone="1{}{}{}".format(second, third, suffix)
        print('手机号:%s'%telephone)
        return telephone


# if __name__=="__main__":
#     C=CreateRanDom()
#     C.r_string()

if __name__ == '__main__':
    Randoms().tax_code()
    Randoms().code()



